package com.ruoyi.storeImage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.storeImage.domain.Storecoverimages;
import com.ruoyi.storeImage.service.IStorecoverimagesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商店封面图片管理Controller
 * 
 * @author ruoyi
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/storeImage/storeImage")
public class StorecoverimagesController extends BaseController
{
    @Autowired
    private IStorecoverimagesService storecoverimagesService;

    /**
     * 查询商店封面图片管理列表
     */
    @PreAuthorize("@ss.hasPermi('storeImage:storeImage:list')")
    @GetMapping("/list")
    public TableDataInfo list(Storecoverimages storecoverimages)
    {
        startPage();
        List<Storecoverimages> list = storecoverimagesService.selectStorecoverimagesList(storecoverimages);
        return getDataTable(list);
    }

    /**
     * 导出商店封面图片管理列表
     */
    @PreAuthorize("@ss.hasPermi('storeImage:storeImage:export')")
    @Log(title = "商店封面图片管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Storecoverimages storecoverimages)
    {
        List<Storecoverimages> list = storecoverimagesService.selectStorecoverimagesList(storecoverimages);
        ExcelUtil<Storecoverimages> util = new ExcelUtil<Storecoverimages>(Storecoverimages.class);
        util.exportExcel(response, list, "商店封面图片管理数据");
    }

    /**
     * 获取商店封面图片管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('storeImage:storeImage:query')")
    @GetMapping(value = "/{imageId}")
    public AjaxResult getInfo(@PathVariable("imageId") Long imageId)
    {
        return success(storecoverimagesService.selectStorecoverimagesByImageId(imageId));
    }

    /**
     * 新增商店封面图片管理
     */
    @PreAuthorize("@ss.hasPermi('storeImage:storeImage:add')")
    @Log(title = "商店封面图片管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Storecoverimages storecoverimages)
    {
        return toAjax(storecoverimagesService.insertStorecoverimages(storecoverimages));
    }

    /**
     * 修改商店封面图片管理
     */
    @PreAuthorize("@ss.hasPermi('storeImage:storeImage:edit')")
    @Log(title = "商店封面图片管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Storecoverimages storecoverimages)
    {
        return toAjax(storecoverimagesService.updateStorecoverimages(storecoverimages));
    }

    /**
     * 删除商店封面图片管理
     */
    @PreAuthorize("@ss.hasPermi('storeImage:storeImage:remove')")
    @Log(title = "商店封面图片管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imageIds}")
    public AjaxResult remove(@PathVariable Long[] imageIds)
    {
        return toAjax(storecoverimagesService.deleteStorecoverimagesByImageIds(imageIds));
    }
}
